package com.strategy.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;

/**
 * 策略执行日志实体类，记录策略执行的关键信息（入参、结果、耗时等）
 */
@Schema(description = "策略执行日志实体类，记录策略执行的关键信息（入参、结果、耗时等）", name = "策略日志")
@TableName("t_strategy_execution_log")
@Getter
@Setter
public class StrategyExecuteLog {

    @Schema(description = "日志ID（主键，自动生成）", example = "123456")
    @TableId(type = IdType.ASSIGN_ID)
    private Long id;

    @Schema(description = "策略标识（关联策略的唯一标识，如'calculator'）", example = "calculator")
    private String strategyKey;

    @Schema(description = "策略版本号（执行时使用的具体版本，如'1.0.0'）", example = "1.0.0")
    private String version;

    @Schema(description = "执行入参（JSON格式字符串，如'{\"value\": 5}'）", example = "{\"value\": 5}")
    private String inputParams;

    @Schema(description = "执行结果（策略返回值的字符串表示，如'15'）", example = "15")
    private String result;

    @Schema(description = "执行状态（0-失败，1-成功）", example = "1")
    private Integer status;

    @Schema(description = "异常信息（执行失败时的错误描述，如'参数缺失：value'）", example = "参数缺失：value")
    private String errorMsg;

    @Schema(description = "执行耗时（单位：毫秒）", example = "200")
    private Long executeTime;

    @Schema(description = "创建时间（日志记录时间，自动填充）", example = "2024-05-20 10:00:00")
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime createTime;

}